package com.zengqingfa.designpattern.behavior.iterator;

/**
 * @author zengqingfa
 * @className ConcreteIterator
 * @description
 * @create 2021/8/25 21:45
 */
public class ConcreteIterator<T> implements Iterator<T> {

    private T[] elements;

    private int position = 0;

    public ConcreteIterator(T[] elements) {
        this.elements = elements;
    }

    @Override
    public boolean hasNext() {
        return position != elements.length;
    }

    @Override
    public T next() {
        T t = elements[position++];
        return t;
    }
}